class TreeNode:
    def __init__(self, val=0, left=None, right=None):
        self.val = val
        self.left = left
        self.right = right


class Solution(object):
    def pathSum(self, root, targetSum):
        result_list = []
        if not root:
            return result_list
        value_list = []

        def search(node, value):
            value_list.append(node.val)
            value += node.val
            if not node.left and not node.right:
                if value == targetSum:
                    add_list = value_list.copy()
                    result_list.append(add_list)
            else:
                if node.left:
                    search(node.left, value)
                if node.right:
                    search(node.right, value)
            value_list.pop()

        search(root, 0)
        return result_list
